﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace XMLReader
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder output = new StringBuilder();

            // XmlXapResolver is the default resolver.
            using (XmlReader reader = XmlReader.Create("book.xml"))
            {
                // Moves the reader to the root element.
                reader.MoveToContent();

                reader.ReadToFollowing("book");
                // Note that ReadInnerXml only returns the markup of the node's children
                // so the book's attributes are not returned.
                output.AppendLine("Read the first book using ReadInnerXml...");
                output.AppendLine(reader.ReadInnerXml());

                reader.ReadToFollowing("book");

                // ReadOuterXml returns the markup for the current node and its children
                // so the book's attributes are also returned.
                output.AppendLine("Read the second book using ReadOuterXml...");
                output.AppendLine(reader.ReadOuterXml());

            }

            Console.Write(output.ToString());
            Console.ReadLine();

        }
    }
}
